package com.cn.mtmming.mtmbizserver;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableEurekaClient
@EnableCircuitBreaker
public class MtmBizServerApplication {

	public static void main(String[] args) {
		SpringApplication.run(MtmBizServerApplication.class, args);
		//如何使用rest的方式以别名的方式进行调用依赖ribbon负载均衡@LoadBalanced
		//@LoadBalanced就可以让RestTemplate在请求时拥有客户端负载均衡的能力
		//@EnableCircuitBreaker开启断路器功能
	}

	//解决RestTemplate  找不到的原因，应该把RestTemplate 注册到SpringBoot的容器中@Bean
	@Bean
	@LoadBalanced
	RestTemplate restTemplate(){
		return  new   RestTemplate();
	}

}
